<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app">

    <!-- <h1 v-if="true">{{msg}}</h1> -->

    <!-- <div v-if="isShow">
      <div >
        {{user.name}}
      </div>
      <div >
        {{user.age}}
      </div>
    </div> -->

    <!-- <template v-if="user.isShow">
      <div >
        {{user.name}}
      </div>
      <div >
        {{user.age}}
      </div>
    </template>

  <template v-else>
    <div>
      {{msg}}
    </div>
  </template> -->

    <template v-if="loginType === 'username'">
      <label>Username</label>
      <input key="username" placeholder="Enter your username">
    </template>
    <template v-else>
      <label>Email</label>
      <input key="email" placeholder="Enter your email address">
    </template>
    
    <button @click="handleClick()">button</button>

    <hr>

    <div id="vif" v-if="user.isShow">
      {{msg}}
    </div>
    <div id="vshow" v-show="user.isShow">
      {{msg}}
    </div>

    <ul>
      <li v-for="n in datalist" v-if="n%2===0"> {{n}}</li>
    </ul>



  </div>

  <script>


    var vm = new Vue({
      //选项
      el: "#app",
      //数据驱动视图
      data: {
        msg: "helloworld",
        loginType: "username",
        user: {
          isShow: true,
          name: 'weitao',
          age: 18
        },
        datalist:[1,2,3,4,5]
      },
      methods: {
        handleClick() {
          if (this.loginType === 'username') {
            this.loginType = 'email'
          } else {
            this.loginType = 'username'
          }
        }
      }



    })



  </script>

</body>

</html>